package com.itqf.quartz;

import com.itqf.job.LogJob;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * projectName: logandquratz2103
 *
 * @author: 赵伟风
 * time: 2021/7/6 16:53
 * description:
 */
public class CronUse {

    public static void main(String[] args) throws SchedulerException {

        //1.创建jobdetail
        JobDetail jobDetail = JobBuilder.newJob(LogJob.class).build();
        //2.crontrigger
        String cron = "30-40 58 * * * ?";
        CronTrigger cronTrigger =
                TriggerBuilder.newTrigger().withSchedule(CronScheduleBuilder.cronSchedule(cron)).build();
        //3.scheduler
        Scheduler scheduler = new StdSchedulerFactory().getScheduler();
        //4.jobdetail trigger --> schedudler
        scheduler.scheduleJob(jobDetail, cronTrigger);

        //5.启动

        scheduler.start();


    }
}
